from __future__ import absolute_import,unicode_literals

from celery import shared_task
from ronglian_sms_sdk import SmsSDK

import json
import random

accId = '8a216da8762cb4570176f483b44f4661'
accToken = '2f2ae6c49fcf4e53b1d63fe9fb8e1544'
appId = '8a216da8762cb4570176f483b57a466f'

@shared_task
def send_message(phone, msg_code):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1' # 容联云分配的一个测试短信验证码模版
    mobile = phone # 接收短信的手机号
    datas = (msg_code, '5')
    sdk.sendMessage(tid, mobile, datas)
    # print(resp)
    # resp_json = json.loads(resp)
    # print(resp_json.get('statusCode'))
